-
Notifications
You must be signed in to change notification settings - Fork 0
feat: #12 server side sorting #66
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks solid against issue #12. The stored average rating, review trigger, stable sort keys and pagination tests are good additions.
Please update the README before approval. It still says the app shows only the first 20 results ordered by relevance and lists sorting and pagination controls as planned, although #62 added pagination and this PR adds sorting. Please make the implemented and planned sections consistent with the current app.
After rebasing on the latest main, resolving the overlaps with #65 and confirming CI passes, this should be ready for approval.
…orting # Conflicts: # client/src/components/ResultsLayout.css # docs/AI-USAGE.md # server/drizzle/meta/0002_snapshot.json # server/drizzle/meta/_journal.json
|
Changes since the review:
The overlap with #65 will be resolved by whichever PR merges second. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested PR #66 locally, including all sorting options, pagination, URL persistence and rating updates. Everything worked as expected, and the full test suite passed, including the PostgreSQL integration tests.
The updated documentation and migration numbering also look good. No further issues found from my testing. Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the README and rebasing on the latest main. The implemented and planned sections now match the current project, and the CI checks pass. Rachel’s review also confirms the sorting, pagination and rating updates work as expected. This addresses my previous feedback.
Closes #12
What was done
Server
AlbumSort:TITLE_DESC,RELEASE_YEAR_ASC,AVERAGE_RATING_ASCandAVERAGE_RATING_DESCare new, andAVERAGE_RATING_DESCno longer throws. The existing enum is extended, not renamed.album.average_rating(migration0002). A trigger onreviewrecalculates it for the one album a review insert, update or delete touches, so the cost does not grow with the catalog. It locks the album row first, so two reviews saved at the same time cannot leave a stale average. The migration fills the column from existing reviews.AVG(), as agreed in the issue, so the cursor has a stable value to seek against.album.idtiebreak, with NULLs last in both directions. Albums with no rating, or no release year, come last.Album.averageRatingnow reads the same column, so the number on a card matches the order.Client
<select>with a visible label). It writes throughsetSortfromuseSearchState, so the sort is in the URL and survives reload, back/forward and shared links.Docs
README.md,docs/architecture.mdanddocs/data-model.mdare updated, and there is a new row indocs/AI-USAGE.md.What was tested
pnpm format:check,lint,typecheck,testand the client build all pass.search.test.ts) check the sort SQL, direction and NULL handling for every sort, the cursor conditions for the new sorts, and the id tiebreak on rating ties.sort.postgres.test.ts(runs whenTEST_DATABASE_URLis set):ORDER BY, with no gaps or duplicates.App.test.tsx: switching sort re-queries with the new sort and updates the URL, and a link with?sort=restores the dropdown.Notes for the reviewer
App.tsx,README.md,docs/architecture.md, the AI-USAGE table). Whichever merges second gets small, easy conflicts.